#pragma once
#include "NEventSubscriber.h"
#include "NeroCore\NRtti.h"
#include <list>

namespace Engine
{
class NEventPublisher : public Core::NRtti
{
	RTTI_DECLARATIONS(NEventPublisher, Core::NRtti)

	typedef  std::list<NEventSubscriber*> SubscriberList;

public:
	NEventPublisher();
	
	NEventPublisher(SubscriberList& subscriberList, bool deleteAfterPublish = false, const double & wallTime = 0.0, const double & delayTime = 0.0);

	virtual ~NEventPublisher();

	void SetTime(const double& currentTime, const double& delay = 0.0);
	
	double GetTimeEnqueued() const;
	
	double GetDelay() const;
	
	bool IsExpired(const double & wallTime) const;
	
	virtual void Deliver() const = 0; 
	
	bool IsDeletedAfterPublishing() const;

protected:
	SubscriberList* mSubscribers;					 //!<
	double mTimeEnqueued;								 //!< initial start time for this event
	double mDelay;									 //!< delay between start time and expiration
	bool mIsDeletedAfterPublishing;					 //!< determines wheather this event should be deleted once expired
};
}